package com.wesley.common.provider.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <h1> 提供者控制器 </h1>
 *
 * @author Wesley.Wei
 * @date 2024-04-24 4:54 下午
 */
@RestController
@RequestMapping("/test")
@RefreshScope
public class ProviderController {

  /**
   * 升级到springCloud之后放弃使用@NacosValue , 使用@Value + @RefreshScope 即可完成自动刷新
   */
  @Value("${name}")
  private String configLocalName;


  @GetMapping("/testConfig")
  public String testConfig() {
    return "testConfig -> " + configLocalName;
  }

  @GetMapping("/hello/{name}")
  public String hello(@PathVariable String name) {
    return "hello " + name;
  }

}